package com.ruoyi.web.controller.ring;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ring.domain.RingMyInfo;
import com.ruoyi.ring.service.IRingMyInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 我的戒指信息Controller
 * 
 * @author liuwp
 * @date 2025-10-15
 */
@RestController
@RequestMapping("/ring/ring_my_info")
public class RingMyInfoController extends BaseController
{
    @Autowired
    private IRingMyInfoService ringMyInfoService;

    /**
     * 查询我的戒指信息列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_my_info:list')")
    @GetMapping("/list")
    public TableDataInfo list(RingMyInfo ringMyInfo)
    {
        startPage();
        List<RingMyInfo> list = ringMyInfoService.selectRingMyInfoList(ringMyInfo);
        return getDataTable(list);
    }

    /**
     * 导出我的戒指信息列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_my_info:export')")
    @Log(title = "我的戒指信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RingMyInfo ringMyInfo)
    {
        List<RingMyInfo> list = ringMyInfoService.selectRingMyInfoList(ringMyInfo);
        ExcelUtil<RingMyInfo> util = new ExcelUtil<RingMyInfo>(RingMyInfo.class);
        util.exportExcel(response, list, "我的戒指信息数据");
    }

    /**
     * 获取我的戒指信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_my_info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ringMyInfoService.selectRingMyInfoById(id));
    }

    /**
     * 新增我的戒指信息
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_my_info:add')")
    @Log(title = "我的戒指信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RingMyInfo ringMyInfo)
    {
        return toAjax(ringMyInfoService.insertRingMyInfo(ringMyInfo));
    }

    /**
     * 修改我的戒指信息
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_my_info:edit')")
    @Log(title = "我的戒指信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RingMyInfo ringMyInfo)
    {
        return toAjax(ringMyInfoService.updateRingMyInfo(ringMyInfo));
    }

    /**
     * 删除我的戒指信息
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_my_info:remove')")
    @Log(title = "我的戒指信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ringMyInfoService.deleteRingMyInfoByIds(ids));
    }
}
